Skip to content

gh-142392: Update ExceptionGroups in docs to use a tuple of errors where possible#142393

Open
dr-carlos wants to merge 1 commit into
python:mainfrom
dr-carlos:exception-group-repr-docs
Open

gh-142392: Update ExceptionGroups in docs to use a tuple of errors where possible#142393
dr-carlos wants to merge 1 commit into
python:mainfrom
dr-carlos:exception-group-repr-docs

Conversation

@dr-carlos

@dr-carlos dr-carlos commented Dec 7, 2025

Copy link
Copy Markdown
Contributor

@picnixz

picnixz commented Dec 7, 2025

Copy link
Copy Markdown
Member

Was it discussed in the PR and deemed a better way alternative? I personally prefer using [] because it's more natural to () on my keyboard but I wonder whether we really need to do mention this in the docs. It's fine to use a list right? I also think it has a nicer rendering as otherwise we have nested (.

@dr-carlos

dr-carlos commented Dec 7, 2025

Copy link
Copy Markdown
Contributor Author

Was it discussed in the PR and deemed a better way alternative? I personally prefer using [] because it's more natural to () on my keyboard but I wonder whether we really need to do mention this in the docs. It's fine to use a list right? I also think it has a nicer rendering as otherwise we have nested (.

It certainly isn't vastly superior, just slightly more efficient. @iritkatriel asked me to open an issue to update the docs, so I opened an issue and PR for it since there aren't many changes.

When you run repr() on an ExceptionGroup, if the original sequence was a list, then we need to create a new list from the eg.exceptions tuple, which could be expensive for a large list. This step is unnecessary for tuples as we just use the repr for eg.exceptions straight-up. So it's slightly more efficient (though of minimal effect for small groups).

@picnixz

picnixz commented Dec 7, 2025

Copy link
Copy Markdown
Member

Yes it could be expensive but exception handlers are usually rare paths, so performance usually aren't an issue here. Unless you have a list of millions of exception objects, it doesn't really matter IMO.

@iritkatriel

Copy link
Copy Markdown
Member

I agree it's not a significant perf impact. My point is it's inconsistent to recommend in the docs to use tuples and then have examples using [].

@dr-carlos

Copy link
Copy Markdown
Contributor Author

@picnixz @iritkatriel Any further thoughts on this?

@github-actions

github-actions Bot commented May 3, 2026

Copy link
Copy Markdown

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label May 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting review docs Documentation in the Doc dir skip news stale Stale PR or inactive for long period of time.

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

3 participants